#include "fuel.h"

Fuel::Fuel()
{
	displayWidth = Iw2DGetSurfaceWidth();
	displayHeight = Iw2DGetSurfaceHeight();

	SetupImages();

	boundingBox = BoundingBox(position, width, height);
}

Fuel::~Fuel()
{
	CleanupImages();
}

void Fuel::SetupImages()
{
	fuelSprite = Iw2DCreateImageResource("fuel");
	width  = fuelSprite->GetWidth();
    height = fuelSprite->GetHeight();
	widthHalf = width / 2;
	heightHalf = height / 2;
}

void Fuel::CleanupImages()
{
	if(fuelSprite != NULL)
	{
		delete fuelSprite;
		fuelSprite = NULL;
	}
}

void Fuel::Render()
{
	Iw2DDrawImage(fuelSprite, CIwSVec2((int16)position.x - widthHalf, (int16)position.y - heightHalf));
}

void Fuel::Update(int deltaTimeMs)
{

}

void Fuel::Spawn()
{
	position = Vector2(Random::Instance()->RandomIntBetween(0, displayWidth), Random::Instance()->RandomIntBetween(0, displayHeight));
	boundingBox.UpdatePosition(position);
}